Skip to content

feat: add elicitation callback support to MCP servers #2373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

yamanahlawat
Copy link
Contributor

@yamanahlawat yamanahlawat commented Jul 30, 2025

Copy link
Contributor

hyperlint-ai bot commented Jul 31, 2025

PR Change Summary

Added support for elicitation callbacks in MCP servers, allowing user interaction during tool execution.

  • Introduced elicitation callback functionality for user input during tool execution.
  • Provided examples for setting up elicitation in MCP server and client.
  • Included practical use case for file deletion confirmation.

Modified Files

  • docs/mcp/client.md

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

@yamanahlawat yamanahlawat requested a review from DouweM July 31, 2025 18:28
Copy link
Collaborator

@DouweM DouweM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yamanahlawat The code and test looks good but the examples are wrong 😅

@yamanahlawat yamanahlawat requested a review from DouweM August 1, 2025 17:21
Copy link
Collaborator

@DouweM DouweM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yamanahlawat Still some issues with the examples, did you verify they actually work? They smell a bit AI generated to me with too little human oversight 😅 I realize this isn't the feature you were initially trying to implement, but unfortunately we can't get to that one until this feature it builds on is solid so I'd appreciate a bit more love for the examples here

@yamanahlawat
Copy link
Contributor Author

@yamanahlawat Still some issues with the examples, did you verify they actually work? They smell a bit AI generated to me with too little human oversight 😅 I realize this isn't the feature you were initially trying to implement, but unfortunately we can't get to that one until this feature it builds on is solid so I'd appreciate a bit more love for the examples here

Guilty as charged. Thanks for the feedback. Here is my updated love for the docs, let me know if any other changes are required.

@yamanahlawat
Copy link
Contributor Author

image

@yamanahlawat yamanahlawat requested a review from DouweM August 2, 2025 09:52
@DouweM
Copy link
Collaborator

DouweM commented Aug 6, 2025

@Kludex Can you please review this as our resident MCP expert? I'm thinking it would be more proper to add our own types instead of directly using those from mcp.

@Kludex
Copy link
Member

Kludex commented Aug 8, 2025

@Kludex Can you please review this as our resident MCP expert? I'm thinking it would be more proper to add our own types instead of directly using those from mcp.

I think it would be easier if we use their types.

@yamanahlawat
Copy link
Contributor Author

yamanahlawat commented Aug 11, 2025

@DouweM Can we merge this? or i'll add the server logic in this PR?



@mcp.tool()
async def use_elicitation(ctx: Context[ServerSessionT, LifespanContextT, RequestT], question: str) -> str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the correct type.

It's probably this:

Suggested change
async def use_elicitation(ctx: Context[ServerSessionT, LifespanContextT, RequestT], question: str) -> str:
async def use_elicitation(ctx: Context[ServerSession, None], question: str) -> str:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i noticed the other mcp test functions (echo_deps, use_sampling) all use Context[ServerSessionT, LifespanContextT, RequestT] as types. for consistency, should we update other functions or is there a reason use_elicitation should use concrete types instead of generics?

Comment on lines +525 to +527
### Supported Schema Types

MCP elicitation supports string, number, boolean, and enum types with flat object structures only. These limitations ensure reliable cross-client compatibility. See [supported schema types](https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation#supported-schema-types) for details.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this section is valuable since the schema type limitations are key constraint that everybody should know. should we move it earlier or completely remove it?

@DouweM DouweM removed their assignment Aug 12, 2025
@yamanahlawat yamanahlawat requested a review from Kludex August 13, 2025 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants